using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
using DanielSig.UnityExtensions;
using DanielSig;
using System.Linq;

[CustomEditor(typeof(Radar))]
[CanEditMultipleObjects]
public class RadarInspector : Editor
{
	/*private static String[] _layerNames;
	
	static RadarInspector()
	{
		_layerNames = new String[]
	}*/
	public override void OnInspectorGUI()
	{
		Radar radar = (Radar)target;
		
		radar.FieldOfView = EditorGUILayout.Slider("Field of View (Degrees)", radar.FieldOfView, 1F, 360F);
		radar.Range = EditorGUILayout.Slider("Range (Meters)", radar.Range, 1F, 360F);
		
		EditorGUILayout.BeginHorizontal();
		
			EditorGUILayout.LabelField("Buffer Size", GUILayout.MaxWidth(70F));
			int newSize = Mathf.Clamp(EditorGUILayout.IntField(radar.VisibleObjects.Length, GUILayout.MaxWidth(50F)), radar.GetComponents<FOVSensor>().Length, 256);
			
			EditorGUILayout.LabelField("   Mask", GUILayout.MaxWidth(50F));
			EditorGUILayout.PropertyField(new SerializedObject(radar).FindProperty("Mask"), new GUIContent(""));
			
			if(newSize != radar.VisibleObjects.Length)
				Array.Resize<Radar.Detection>(ref radar.VisibleObjects, newSize);
			
		EditorGUILayout.EndHorizontal();
	}
}